<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
     
    <input type="text" name="" id="i1">
    <span id="s1"></span>



    <script>
         i1.onblur=function(){
    var reg= /^(\d|\d{2}|1\d{2}|2[0-4]\d|25[0-5])$/;
        if(reg.test(i1.value)){
            s1.innerHTML="验证成功"
        }else{
            s1.innerHTML="验证失败"
        }
        }

    </script>
</body>
</html>